<template>
  <div class="commentItem">
    <!-- <div class="commentItem" v-if="comment.parent">
      <div class="commentItem" v-if="comment.parent.parent">
        <div class="top">
          <div class="left">
            <span>{{ comment.parent.parent.user.nickname }}</span>
            &nbsp;&nbsp;&nbsp;
            <span>2分钟前</span>
          </div>
          <span>回复</span>
        </div>
        <div class="bottom">{{ comment.parent.parent.content }}</div>
      </div>

      <div class="top">
        <div class="left">
          <span>{{ comment.parent.user.nickname }}</span> &nbsp;&nbsp;&nbsp;
          <span>2分钟前</span>
        </div>
        <span>回复</span>
      </div>
      <div class="bottom">{{ comment.parent.content }}</div>
    </div> -->
    <ci
      v-if="comment.parent"
      :comment="comment.parent"
      @parentReply="reply"
    ></ci>
    <div class="top">
      <div class="left">
        <span>{{ comment.user.nickname }}</span> &nbsp;&nbsp;&nbsp;
        <span>2分钟前</span>
      </div>
      <span @click="reply(comment)" class="reply">回复</span>
    </div>
    <div class="bottom">{{ comment.content }}</div>
  </div>
</template>

<script>
export default {
  name: "ci",
  props: {
    // 当前需要渲染的评论数据对象
    comment: {
      type: Object,
    },
  },
  methods: {
    reply(comment) {
      // 子传父
      this.$emit("parentReply", comment);
    },
  },
};
</script>

<style lang="less" scoped>
.commentItem {
  border: 1px solid #ccc;
  padding: 5px;
  margin-top: 10px;
  .top {
    font-size: 12px;
    color: #aaa;
    display: flex;
    justify-content: space-between;
  }
  .bottom {
    font-size: 13px;
    line-height: 40px;
  }
}
.reply {
  z-index: 11;
  color: #f00;
}
</style>